package com.base64;


import java.io.UnsupportedEncodingException;
import java.util.Base64;

public class Base64D{
	public static void main(String[] args) throws UnsupportedEncodingException {
		String ss=";我;";
		System.out.println(encode(ss));
		System.out.println(dec(encode(ss)));
		
		
		

	}
//		编码
	public static String encode(String s) throws UnsupportedEncodingException {
		if (s == null || "".equals(s))
			return "";
		return new String(Base64.getEncoder().encode(s.getBytes()), "utf-8");
	}
	//	解码
	public static String dec(String s) throws UnsupportedEncodingException {
		if (s == null || "".equals(s))
			return "";
		return new String(Base64.getDecoder().decode(s.getBytes()), "utf-8");
	}

}
